package megalopolis.common;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

/**
 * User: Kirill
 * Date: 19.02.2008
 */
public class Config {

	private ResourceBundle bundle;

	public Config(String filename) throws IOException {
		this.bundle = new PropertyResourceBundle(new FileInputStream(filename));
	}

	public int getInt(String key) {
		String str = getString(key);
		if (str.startsWith("0x")) {
			return Integer.parseInt(str.substring(2), 16);
		} else {
			return Integer.parseInt(str);
		}
	}

	public String getString(String key) {
		return bundle.getString(key);
	}
}
